<?php
 /*
 * 1626cms 系統設置
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once('../data/config.php');
require_once('./include/admin_common.inc.php');
require_once(ADMIN_ROOT_PATH.'include/admin_settings_fun.php');
$act = !empty($_GET['act']) ? trim($_GET['act']) : 'site_set';
//*******************************網站基本設置
//網站設置
if($act == 'site_set'){
$smarty->assign('config',get_cache('config',true));
$smarty->assign('rand',rand(1,100));//隨機數
$smarty->assign('upfiles_dir',$upfiles_dir);//上傳目錄
$smarty->assign('act',$act);//標簽ID
$smarty->assign('pageheader',"管理中心 - 系統設置 - 網站設置");
$smarty->display('admin_settings_site_set.htm');
}
//保存系網站設置
if($act == 'site_setsave'){
require_once(ADMIN_ROOT_PATH.'include/upload_img.php');
if($_FILES['web_logo']['name'])
{
$web_logo=_asUpFiles($upfiles_dir, "web_logo", 1024*2, 'jpg/gif/png',"logo");
!$db->query("UPDATE ".table("config")." SET value='$web_logo' WHERE name='web_logo'")?showmsg('更新站點設置失敗', 1):"";
}
foreach($_POST as $k => $v){
!$db->query("UPDATE ".table("config")." SET value='$v' WHERE name='$k'")?showmsg('更新站點設置失敗', 1):"";
}
get_cache('config',true);
showmsg("保存成功！",2);
}
//關鍵字過濾設置--------------------------
if($act == 'site_filter'){
$smarty->assign('config',get_cache('config',true));
$smarty->assign('pageheader',"管理中心 - 系統設置 - 關鍵字過濾設置");
$smarty->display('admin_settings_site_filter.htm');
}
//保存關鍵字過濾設置
if($act == 'site_filtersave'){
foreach($_POST as $k => $v){
!$db->query("UPDATE ".table("config")." SET value='$v' WHERE name='$k'")?showmsg('更新站點設置失敗', 1):"";
}
get_cache('config',true);
showmsg("保存成功！",2);
}
//IP過濾設置--------------------------
if($act == 'filter_ip'){
$smarty->assign('config',get_cache('config',true));
$smarty->assign('pageheader',"管理中心 - 系統設置 - ip過濾設置");
$smarty->display('admin_settings_site_filter_ip.htm');
}
//后臺快捷按鈕設置--------------------------
if($act == 'site_admin_navigation'){
$smarty->assign('pageheader',"管理中心 - 系統設置 - 后臺快捷按鈕");
$smarty->assign('category',get_admin_navigation());
$smarty->assign('category_list',get_admin_navigation_all());
$smarty->display('admin_settings_site_admin_navigation.htm');
}
//保存后臺快捷設置
if($act == 'site_admin_navigation_save'){
!empty($_POST['is_show'])&& is_array($_POST['is_show']) ? '' : showmsg('請至少選擇一個項目',1);
$post_show=implode(",", $_POST['is_show']);
!$db->query("UPDATE ".table("admin_navigation")." SET is_show='1' WHERE id in (".$post_show.")")?showmsg('保存失敗', 1):"";
!$db->query("UPDATE ".table("admin_navigation")." SET is_show='0' WHERE id not in (".$post_show.")")?showmsg('保存失敗', 1):"";
$y_num=count($_POST['is_show']);
for($i=0;$i<$y_num;$i++)
{
!$db->query("UPDATE ".table("admin_navigation")." SET category_order='".$_POST['category_order'][$i]."' WHERE id='".$_POST['is_show'][$i]."'")?showmsg('保存失敗', 1):"";
}
echo ("<script>window.parent.topFrame.location.href='admin_index.php?act=top';</script>");
showmsg("保存成功！",2);
}
//頁面緩存設置
if($act == 'site_cacheperiod'){
$smarty->assign('cacheperiod',get_cache('cacheperiod',true));
$smarty->assign('pageheader',"管理中心 - 系統設置 - 頁面緩存設置");
$smarty->display('admin_settings_site_cacheperiod.htm');
}
//保存緩存設置
if($act == 'save_cacheperiod'){
foreach($_POST as $k => $v){
!$db->query("UPDATE ".table("cacheperiod")." SET value='$v' WHERE name='$k'")?showmsg('更新緩存設置失敗', 1):"";
}
get_cache('cacheperiod',true);
showmsg("保存成功！",2);
}
//電子地圖設置
if($act == 'site_set_map'){
$smarty->assign('config',get_cache('config',true));
$smarty->assign('pageheader',"管理中心 - 系統設置 - 電子地圖設置");
$smarty->display('admin_settings_site_map.htm');
}
//會員注冊協議
if($act == 'agreement'){
$smarty->assign('agreement',get_agreement());//注冊協議
$smarty->assign('pageheader',"管理中心 - 系統設置 - 會員注冊協議");
$smarty->display('admin_settings_agreement.htm');
}
//保存會員注冊協議
if($act == 'agreement_save'){
$content=$_POST['content'];
if ($content)
{
!$db->query("UPDATE ".table("agreement")." SET content='".$content."' WHERE id=1")?showmsg('保存失敗', 1):"";
showmsg("保存成功！",2);
}
}
//前臺導航設置--------------------------
if($act == 'site_navigation'){
$smarty->assign('pageheader',"管理中心 - 系統設置 - 導航設置");
$smarty->assign('list',get_navigation(1));
$smarty->display('admin_settings_site_navigation.htm');
}
//保存導航設置（所有）
if($act == 'site_navigation_all_save')
{
$id=$_POST['id'];
$title=$_POST['title'];
$navigationorder=$_POST['navigationorder'];
$id_num=count($id);
for($i=0;$i<$id_num;$i++)
{
$sql="update ".table('navigation')." set title='".$title[$i]."',navigationorder='".$navigationorder[$i]."'  where id='".intval($id[$i])."'";
$db->query($sql);
}
showmsg("修改成功！",2);
}
//添加導航欄目
if($act == 'site_navigation_add')
{
$smarty->assign('pageheader',"管理中心 - 系統設置 - 導航設置 - 添加新欄目");
$smarty->assign('typeid',"1");//1表示分類欄目分類為1
$smarty->display('admin_settings_site_navigation_add.htm');
}
//保存添加導航欄目
if($act == 'site_navigation_add_save')
{
$setsqlarr['title']=trim($_POST['title'])?trim($_POST['title']):showmsg('您沒有填寫欄目名稱！',1);
$setsqlarr['url']=trim($_POST['url'])?trim($_POST['url']):showmsg('您沒有填寫鏈接地址！',1);
$setsqlarr['target']=trim($_POST['target'])?trim($_POST['target']):showmsg('您沒有填寫打開方式！',1);
$setsqlarr['navigationorder']=$_POST['navigationorder'];
$setsqlarr['typeid']=$_POST['typeid'];
$setsqlarr['display']=$_POST['display'];
$setsqlarr['notes']="自定義欄目";
$setsqlarr['systemclass']="0";//0為普通欄目，1為系統分類
$link[0]['text'] = "返回列表";
$link[0]['href'] ="?act=site_navigation";
!inserttable(table('navigation'),$setsqlarr)?showmsg("添加失敗！",0):showmsg("添加成功！",2,$link);
}
//刪除導航欄目
if($act == 'del_navigation')
{
$id=$_GET['id'];
$link[0]['text'] = "返回列表";
$link[0]['href'] ="?act=site_navigation";
!del_navigation($id)?showmsg("刪除失敗！",0):showmsg("刪除成功！",2,$link);
}
//編輯導航欄目
if($act == 'site_navigation_edit')
{
$id=$_GET['id'];
$smarty->assign('pageheader',"管理中心 - 系統設置 - 導航設置 - 修改");
$smarty->assign('list',get_navigation_one($id));
$smarty->display('admin_settings_site_navigation_edit.htm');
}
//編輯保存導航欄目
if($act == 'site_navigation_edit_save')
{
$setsqlarr['title']=trim($_POST['title'])?trim($_POST['title']):showmsg('您沒有填寫欄目名稱！',1);
if ($_POST['systemclass']!="1")
{
$setsqlarr['url']=trim($_POST['url'])?trim($_POST['url']):showmsg('您沒有填寫鏈接地址！',1);
}
$setsqlarr['target']=trim($_POST['target'])?trim($_POST['target']):showmsg('您沒有填寫打開方式！',1);
$setsqlarr['navigationorder']=$_POST['navigationorder'];
$setsqlarr['display']=$_POST['display'];
$link[0]['text'] = "返回列表";
$link[0]['href'] ="?act=site_navigation";
$wheresql=" id='".intval($_POST['id'])."'";
!updatetable(table('navigation'),$setsqlarr,$wheresql)?showmsg("修改失敗！",0):showmsg("修改成功！",2,$link);
}
?>
